from django.conf.urls.defaults import *
from django.conf import settings

from django.contrib import admin
admin.autodiscover()

from django.contrib import databrowse

urlpatterns = patterns('',
    (r'^admin/doc/', include('django.contrib.admindocs.urls')),
    (r'^admin/(.*)', admin.site.root),

    #(r'^databrowse/(.*)', databrowse.site.root),

    (r'^accounts/login/$', 'django.contrib.auth.views.login', {}, 'login'),
    (r'^accounts/logout/$', 'django.contrib.auth.views.logout', {}, 'logout'),

    (r'^', include('browsertests.main.urls')),

    (r'^specs/', include('browsertests.specs.urls')),
    (r'^tests/', include('browsertests.tests.urls')),
    (r'^results/', include('browsertests.results.urls')),
    (r'^useragents/', include('browsertests.useragents.urls')),
)

if settings.DEBUG or settings.STATIC_URLS:
    urlpatterns += patterns('',
        (r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
         {'document_root': settings.MEDIA_ROOT}),
    )
    if hasattr(settings, "TESTS_PATH"):
        urlpatterns += patterns('',
            (r'^test_files/(?P<path>.*)$', 'django.views.static.serve',
             {'document_root': settings.TESTS_PATH}),
        )
    if hasattr(settings, "REFTEST_RESULTS_PATH"):
        urlpatterns += patterns('',
            (r'^reftest_results/(?P<path>.*)$', 'django.views.static.serve',
             {'document_root': settings.REFTEST_RESULTS_PATH}),
        )

# Databrowse
#from django.contrib import databrowse
#from browsertests.tests.models import Test
#from browsertests.results.models import Result
#databrowse.site.register(Test)
#databrowse.site.register(Result)
